package com.fig.spring;

import com.fig.spring.beans.Cat;
import com.fig.spring.beans.Person;
import com.fig.spring.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@ComponentScan("com.fig.spring")
public class AnnotationMainTest {
	public static void main(String[] args) {
	/*	ApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);*/
	/*	String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
		for (String name:
			 beanDefinitionNames) {
			System.out.println(name);
		}

		Cat cat1 = applicationContext.getBean(Cat.class);
		Cat cat2 = applicationContext.getBean(Cat.class);
		System.out.println("Cat:");
		System.out.println(cat1==cat2);*/
		/*Person bean = applicationContext.getBean(Person.class);
		System.out.println(bean);*/


		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
		Person bean = context.getBean(Person.class);
		Person bean2 = 	context.getBean(Person.class);
		System.out.println("Person:");
		Cat cat = bean.getCat();
		Cat cat3 = bean2.getCat();
		System.out.println(cat3==cat);
	}
}
